<template>
  <div class="globalSider">
    <a-layout-sider
      v-if="loginUserStore.loginUser.id"
      width="200"
      breakpoint="lg"
      collapsed-width="0"
    >
      <a-menu
        v-model:selectedKeys="current"
        mode="inline"
        :items="menuItems"
        @click="doMenuClick"
      />
    </a-layout-sider>
  </div>
</template>

<script setup lang="ts">
import { useLoginUserStore } from '@/stores/user.ts'
import { PictureOutlined,UserOutlined } from '@ant-design/icons-vue';
import { h, ref } from 'vue'
import { useRouter } from 'vue-router'

const loginUserStore = useLoginUserStore()
const menuItems = [
  {
    key: '/',
    label: '公共空间',
    icon: () => h(PictureOutlined)
  },
  {
    key: '/my_space',
    label: '我的空间',
    icon: () => h(UserOutlined)
  }
]
const router = useRouter()
const current = ref<string[]>([])
router.afterEach(((to, from, next) => {
  current.value = [to.path]
}))
const doMenuClick = ({ key }: { key: string}) => {
  router.push({
    path: key,
  });
}
</script>
#globalSider .ant-layout-sider {
background: none;
}s
<style scoped>

</style>
